﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Infinity.Models;

namespace Infinity.Areas.Managerial.Controllers
{
    public class salaryInstructorCourseController : Controller
    {
        private InfinityEntities db = new InfinityEntities();

        //
        // GET: /salaryInstructorCourse/
      
        public ActionResult Index()
        {
            var instructor_course_salary = db.Instructor_Course_Salary.Include(i => i.Course).Include(i => i.Instructor).Include(i => i.Instructor_Salary);
            return View(instructor_course_salary.ToList());
        }

        //
        // GET: /salaryInstructorCourse/Details/5



        //
        // GET: /salaryInstructorCourse/Create

        public ActionResult Create()
        {
            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Course_Name");
            ViewBag.InstructorID = new SelectList(db.Instructors, "InsructorID", "Name");
            ViewBag.SalaryID = new SelectList(db.Instructor_Salary, "Salary_Id", "SalaryType");
            return View();
        }

        //
        // POST: /salaryInstructorCourse/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(Instructor_Course_Salary instructor_course_salary)
        {
            if (ModelState.IsValid)
            {
                db.Instructor_Course_Salary.Add(instructor_course_salary);
                db.SaveChanges();

                //return RedirectToAction("Index");
            }

            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Course_Name", instructor_course_salary.CourseID);
            ViewBag.InstructorID = new SelectList(db.Instructors, "InsructorID", "Name", instructor_course_salary.InstructorID);
            ViewBag.SalaryID = new SelectList(db.Instructor_Salary, "Salary_Id", "SalaryType", instructor_course_salary.SalaryID);
            return View(instructor_course_salary);
        }

       

        public ActionResult Edit(int CourseID,int InstructorID,int SalaryID)
        {
            Instructor_Course_Salary instructor_course_salary = db.Instructor_Course_Salary.Find(CourseID,InstructorID,SalaryID);
            if (instructor_course_salary == null)
            {
                return HttpNotFound();
            }
            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Course_Name", instructor_course_salary.CourseID);
            ViewBag.InstructorID = new SelectList(db.Instructors, "InsructorID", "Name", instructor_course_salary.InstructorID);
            ViewBag.SalaryID = new SelectList(db.Instructor_Salary, "Salary_Id", "SalaryType", instructor_course_salary.SalaryID);
            return View(instructor_course_salary);
        }

        //
        // POST: /salaryInstructorCourse/Edit

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(Instructor_Course_Salary instructor_course_salary)
        {
            if (ModelState.IsValid)
            {
                db.Entry(instructor_course_salary).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Course_Name", instructor_course_salary.CourseID);
            ViewBag.InstructorID = new SelectList(db.Instructors, "InsructorID", "Name", instructor_course_salary.InstructorID);
            ViewBag.SalaryID = new SelectList(db.Instructor_Salary, "Salary_Id", "SalaryType", instructor_course_salary.SalaryID);
            return View(instructor_course_salary);
        }

        //
        // GET: /salaryInstructorCourse/Delete/5

        public ActionResult Delete(int id = 0)
        {
            Instructor_Course_Salary instructor_course_salary = db.Instructor_Course_Salary.Find(id);
            if (instructor_course_salary == null)
            {
                return HttpNotFound();
            }
            return View(instructor_course_salary);
        }

        //
        // POST: /salaryInstructorCourse/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            Instructor_Course_Salary instructor_course_salary = db.Instructor_Course_Salary.Find(id);
            db.Instructor_Course_Salary.Remove(instructor_course_salary);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}